<div class="uk-clearfix list-header">
  <h4 class="tm-article-subtitle uk-float-left"> 用户管理</h4>

  <div class="uk-float-right">
    <%= link_to new_backend_user_path, class: 'uk-button uk-button-success' do %>
      <i class="uk-icon-plus"></i> 新增
    <% end %>
  </div>
</div>
<hr>
<div class="list-search uk-form">
  <%= search_form_for @search, url: backend_users_path, html: {class: 'form'} do |f| %>
    <%= f.text_field :name_cont, placeholder: '填写姓名' %>
    <label class="uk-form-label">性别</label>
    <%= f.select :gender_eq, @users.options_for_enum_select(:genders, raw: true), include_blank: '全部性别' %>
    <label class="uk-form-label">类型</label>
    <%= f.select :kind_eq, @users.options_for_enum_select(:kinds, raw: true), include_blank: '全部类型' %>
    <label class="uk-form-label"> 状态 </label>
    <%= f.select :status_eq, @users.options_for_enum_select(:statuses, raw: true), include_blank: '全部状态' %>
    <button class="uk-button">搜索</button>
  <% end %>
</div>

<div class="uk-margin-top list-body">
  <div class="uk-overflow-container thin-scroll" style="min-height: calc(100vh - 220px);max-height:calc(100vh - 220px); ">
    <table class="uk-table uk-table-hover uk-table-striped uk-table-condensed  horizontal-scroll" border="1">
      <thead>
      <tr>
        <th>
          <%= sort_link @search, :name do %>
            昵称
          <% end %>
        </th>
        <th>
          <%= sort_link @search, :gender do %>
            性别
          <% end %>
        </th>
        <th>
          <%= sort_link @search, :kind do %>
            类型
          <% end %>
        </th>
        <th>
          <%= sort_link @search, :status do %>
            状态
          <% end %>
        </th>
        <th>
          <%= sort_link @search, :created_at do %>
            创建时间
          <% end %>
        </th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody>
      <% @users.each do |user| %>
        <tr>
          <td><%= user.name %></td>
          <td><%= user.enum_name(:gender) %></td>
          <td><%= user.enum_name(:kind) %></td>
          <td>
            <%= link_to switch_backend_user_path(user), method: :put, data: {confirm: "确认#{user.active? ? '禁用' : '启用'}该用户吗？"}, class: "uk-button uk-button-mini #{'uk-button-primary' if user.active?}" do %>
              <%= user.enum_name(:status) %>
            <% end %>
          </td>
          <td><%= flatten_time user.created_at %></td>
          <td>
            <%= link_to edit_backend_user_path(user), class: 'uk-button uk-button-mini uk-button-primary' do %>
              <i class="uk-icon-edit"></i> 修改
            <% end %>
            <%= link_to backend_user_path(user), class: 'uk-button uk-button-mini uk-button-primary' do %>
              <i class="uk-icon-list"></i> 详情
            <% end %>
          </td>
        </tr>
      <% end %>
      </tbody>
    </table>
    <div class="paginate-info uk-clearfix uk-margin-bottom">
      <div class="uk-float-left">
        <%= paginate_info(@users) %>
      </div>
      <div class="uk-float-right">
        <%= paginate @users, theme: 'admin' %>
      </div>
    </div>

  </div>
</div>
